home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / setvbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  649 b   |  32 lines

  1. /* was from Dale Schumacher's dLibs library */
  2. /* totally different now */
  3.  
  4. #include <stdio.h>
  5. #include <limits.h>
  6. #include <memory.h>
  7.  
  8. int setvbuf(fp, bp, bmode, size)
  9. register FILE *fp;
  10. char *bp;
  11. int bmode;
  12. size_t size;
  13. {
  14.     if(fp->_flag & _IOMYBUF)
  15.     free(fp->_base);
  16.     fp->_flag &= ~(_IOFBF | _IOLBF | _IONBF | _IOMYBUF);
  17.     fp->_flag |= bmode;
  18.     fp->_cnt = 0;
  19.     if((bmode == _IONBF) || (bp == NULL))        /* unbuffered */
  20.     {
  21.     fp->_base = &(fp->_ch);            /* use tiny buffer */
  22.     fp->_bsiz = 1;
  23.     }
  24.     else                        /* full buffering */
  25.     {
  26.     fp->_base = (unsigned char *)bp;
  27.     fp->_bsiz = size;
  28.     }
  29.     fp->_ptr = fp->_base;
  30.     return 0;
  31. }
  32.